Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@yarnpkg/pnp
Advanced tools
@yarnpkg/pnp is a package that provides Plug'n'Play (PnP) functionality for Yarn, a popular JavaScript package manager. PnP is a feature that eliminates the need for a node_modules directory by resolving dependencies directly from the Yarn cache, leading to faster installs and more efficient disk usage.
Dependency Resolution
This feature allows you to resolve the path to a dependency without needing a node_modules directory. The code sample demonstrates how to resolve the path to the 'lodash' package.
const { resolveToUnqualified, resolveUnqualified } = require('@yarnpkg/pnp');
const unqualifiedPath = resolveToUnqualified('lodash', __filename);
const qualifiedPath = resolveUnqualified(unqualifiedPath, 'lodash');
console.log(qualifiedPath);
Package Information
This feature provides detailed information about a specific package, such as its location and dependencies. The code sample shows how to retrieve information for the 'lodash' package.
const { getPackageInformation } = require('@yarnpkg/pnp');
const packageLocator = { name: 'lodash', reference: '4.17.21' };
const packageInfo = getPackageInformation(packageLocator);
console.log(packageInfo);
Custom Resolvers
This feature allows you to create custom resolvers for specific packages. The code sample demonstrates how to create a custom resolver for a package named 'custom-package'.
const { makeResolver } = require('@yarnpkg/pnp');
const customResolver = makeResolver({
resolveToUnqualified: (request, issuer) => {
if (request === 'custom-package') {
return '/path/to/custom-package';
}
return null;
}
});
console.log(customResolver.resolveToUnqualified('custom-package', __filename));
npm is the default package manager for Node.js. Unlike @yarnpkg/pnp, npm uses a node_modules directory to store dependencies, which can lead to slower installs and more disk usage.
pnpm is a fast, disk space-efficient package manager. It uses a content-addressable file system to store all files from all module directories in a single place, which is somewhat similar to PnP's approach of avoiding node_modules.
Rush is a scalable monorepo manager for the web. It supports multiple package managers, including Yarn with PnP, and focuses on managing large repositories with many projects.
FAQs
Unknown package
The npm package @yarnpkg/pnp receives a total of 120,861 weekly downloads. As such, @yarnpkg/pnp popularity was classified as popular.
We found that @yarnpkg/pnp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.